<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRepayRecordCommonsTable extends Migration
{
    private $table = 'repay_record_commons';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';
            $table->comment = '还款分期记录公共接口表(平台自收)';
            $table->increments('id');
            $table->unsignedInteger('uid')->comment('关联用户id');
            $table->unsignedInteger('summary_id')->comment('关联还款表id');
            $table->unsignedInteger('record_id')->comment('关联还款记录表id');
            $table->unsignedInteger('bank_cards_id')->comment('关联user_bank_cards银行卡id');
            $table->string('third_record_id', 255)->default('')->comment('资方接口返回,公共请求id');
            $table->string('trade_no', 255)->default('')->comment('平台内唯一流水号');
            $table->unsignedTinyInteger('period')->comment('当前期数,0为全部还清记录');
            $table->unsignedInteger('lending_money')->default(0)->comment('利息费,以分为单位');
            $table->unsignedInteger('fines_money')->default(0)->comment('罚息费,以分为单位');
            $table->unsignedInteger('manage_money')->default(0)->comment('贷后管理费,以分为单位');
            $table->unsignedInteger('repayment_money')->default(0)->comment('提前还款手续费,以分为单位');
            $table->string('failure', 255)->default('')->comment('失败原因');
            $table->unsignedTinyInteger('status')->default(1)->comment('蔚捷接口状态 1:待处理,2:处理中,3:失败,4:成功');
            $table->timestamp('apply_time')->nullable()->comment('接口申请时间');
            $table->timestamp('status_time')->nullable()->comment('接口处理成功/失败时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
}
